import router from '@system.router';
import prompt from '@system.prompt';
import http from '@ohos.net.http';
export default {
    data: {
        title: "",
        nowtime:String,
        year:Number,
        month:Number,
        date:Number,
        hour:Number,
        minute:Number,
        seconds:Number,
        datas:"数据"
    },
    onInit() {
        this.title = "Hello World";
    },
//    dianji1(){
//        let url = "http://120.46.171.116:8082/get_specified_muscle_data";
//        let httpRequest = http.createHttp();
//        httpRequest.request(
//            url,
//            {
//                method: http.POST, // 可选，默认为http.RequestMethod.GET
//                extraData: {
//                    account:"15565988801",
//                    time:"20230205003830"
//                },
//            }, (err, data) => {
//            if (!err) {
//                prompt.showToast({
//                    message:"成功"
//                })
//                this.datas = data.result
//                console.info("成功"+"data:"+data.result)
//            } else {
//                prompt.showToast({
//                    message:"失败"
//                })
//                console.info("失败")
//            }
//        }
//        );
//    },
    dianji(){
        var now = new Date();
        this.year = now.getFullYear()
        this.month = now.getMonth()+1
        this.date = now.getDate()
        this.hour = now.getHours()+8
        this.minute = now.getMinutes()
        this.seconds = now.getSeconds()
        if(now.getMonth()+1<10){
            this.month = "0"+ (now.getMonth()+1)
        }
        if(now.getDate()<10){
            this.date = "0"+ now.getDate()
        }
        if(now.getHours()+8<10){
            this.hour = "0"+ (now.getHours()+8)
        }
        if(now.getMinutes()<10){
            this.minute = "0"+ now.getMinutes()
        }
        if(now.getSeconds()<10){
            this.seconds = "0"+ now.getSeconds()
        }
        this.nowtime = this.year.toString() + this.month + this.date + this.hour+ this.minute+this.seconds
        console.info("年："+this.year+"月："+this.month+"日："+this.date+"时："+this.hour+"分:"+this.minute+"秒:"+this.seconds)
        let url = "http://120.46.171.116:8082/get_specified_kneading_data";
        let httpRequest = http.createHttp();
        httpRequest.request(
            url,
            {
                method: http.POST, // 可选，默认为http.RequestMethod.GET
                extraData: {
                    account:"15565988801",
                    time:"20230221233410"
                },
            }, (err, data) => {
            if (!err) {
                prompt.showToast({
                    message:"成功"
                })
                this.datas = data.result
                console.info("成功"+"data:"+data.result)
            } else {
                prompt.showToast({
                    message:"失败"
                })
                console.info("失败")
            }
        }
        );
    },
    dianji2(){
        router.push({
            uri:"pages/test2/test2",
            params:{
                title:22222
            }
        })
    }
}
